import time
import datetime
from PyCmpltrtok.common import sep, delta2milli

FMT = '%Y-%m-%d %H:%M:%S'
FMTWithMicro = '%Y-%m-%d %H:%M:%S.%f'

sep('my birth day')
xmy_birth_dt = datetime.datetime(1983, 1, 30, 4, 10, 11)
print(xmy_birth_dt.isoformat())

sep('now')
xnowdt = datetime.datetime.now()
print(xnowdt.isoformat())

sep('delta')
xdiff = xnowdt - xmy_birth_dt
print(repr(xdiff))
xdiff_days = xdiff.days
print(f'diff days: {xdiff_days}')
print(f'diff years: {xdiff_days / 365:,.4f}')
print(f'diff seconds: {xdiff.seconds}')
print(f'diff microseconds: {xdiff.microseconds}')
print(f'diff milli: {delta2milli(xdiff)}')

dt1 = datetime.datetime(2023, 3, 1, 1, 0, 0)
dt2 = datetime.datetime(2023, 3, 1, 1, 0, 33)
print(f'diff milli: {delta2milli(dt2 - dt1)}')

dt2 = datetime.datetime(2023, 3, 1, 1, 3, 33)
print(f'diff milli: {delta2milli(dt2 - dt1)}')

dt2 = datetime.datetime(2023, 3, 1, 4, 3, 33)
print(f'diff milli: {delta2milli(dt2 - dt1)}')

dt2 = datetime.datetime(2023, 3, 4, 4, 3, 33)
print(f'diff milli: {delta2milli(dt2 - dt1)}')
